﻿using Basic.FormGatewaryModular.Interface;
using Basic.FormRemoteModel.Page;
using Basic.FormRemoteModel.Page.Model;
using Basic.FormRemoteModel.PageBody;
using Basic.FormRemoteModel.PageBody.Model;
using WeDonekRpc.Client;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FormGatewaryModular.Services
{
    internal class CustomPageService : ICustomPageService
    {
        public void AddPower ( long id, PageAppPower power )
        {
            new AddPagePower
            {
                Id = id,
                Power = power
            }.Send();
        }
        public void Enable ( long id )
        {
            new EnableCustomPage
            {
                Id = id
            }.Send();
        }
        public void Disable ( long id )
        {
            new DisableCustomPage
            {
                Id = id
            }.Send();
        }
        public long Add ( PageAdd add )
        {
            return new AddCustomPage
            {
                Datum = add
            }.Send();
        }
        public PageControlDto GetLayout ( long layoutId, bool isEdit )
        {
            return new GetPageLayout
            {
                LayoutId = layoutId,
                IsEdit = isEdit
            }.Send();
        }
        public PageBodyDto GetBody ( long id, bool isEdit )
        {
            return new GetPageBody
            {
                Id = id,
                IsEdit = isEdit
            }.Send();
        }

        public void Delete ( long id )
        {
            new DeleteCustomPage
            {
                Id = id
            }.Send();
        }

        public PageDatum Get ( long id )
        {
            return new GetCustomPage
            {
                Id = id
            }.Send();
        }

        public PagingResult<PageDatum> Query ( PagingParam<PageQueryParam> query )
        {
            return new QueryCustomPage
            {
                Index = query.Index,
                Size = query.Size,
                SortName = query.SortName,
                IsDesc = query.IsDesc,
                NextId = query.NextId,
                Query = query.Query
            }.Send();
        }

        public bool Set ( long id, PageSet set )
        {
            return new SetCustomPage
            {
                Id = id,
                Datum = set
            }.Send();
        }

        public PageAppPower GetPower ( long id )
        {
            return new GetPagePower
            {
                Id = id
            }.Send();
        }
    }
}
